home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2003 December / The Sunday Times - The Month 2003-12.iso / pc / engine / shell / shell.swf / scripts / DefineSprite_104 / frame_1 / DoAction.as
Encoding:
Text File  |  2003-11-10  |  4.7 KB  |  177 lines

  1. function load()
  2. {
  3.    loaded = false;
  4.    xmlData = new XML();
  5.    xmlData.ignoreWhite = true;
  6.    xmlData.onLoad = function(success)
  7.    {
  8.       delete this.onLoad;
  9.       loaded = true;
  10.       drawLayout();
  11.       onDataLoaded();
  12.    };
  13.    var strFile = "xml/content/" + Tardis.ActiveSection.id + "/" + Tardis.ActiveItem.attributes.xmlfile + ".xml";
  14.    xmlData.path = strFile;
  15.    strFile = Tardis.ASSETS_FOLDER + strFile + (Tardis.PLAY_MODE != "browser" ? "" : "?random=" + random(1000000));
  16.    xmlData.load(strFile);
  17. }
  18. function exit()
  19. {
  20.    delete xmlData;
  21.    loaded = false;
  22.    gotoAndStop(2);
  23.    Tardis.onItemExit();
  24. }
  25. function show()
  26. {
  27.    setShowHide(true);
  28. }
  29. function hide()
  30. {
  31.    setShowHide(false);
  32. }
  33. function interrupt()
  34. {
  35.    setInterruptResume(false);
  36. }
  37. function resume()
  38. {
  39.    setInterruptResume(true);
  40. }
  41. function loadBespokeSection()
  42. {
  43.    var S = Tardis.ActiveSection;
  44.    gotoAndStop("l_" + S.layout);
  45.    var mc = mcTL;
  46.    if(S.sandbox != "true")
  47.    {
  48.       mc.loadMovie(Tardis.ASSETS_FOLDER + "bespoke/" + S.file);
  49.    }
  50.    else
  51.    {
  52.       nodeSectionData = new XML("<bespoke width=\"" + S.width + "\" height=\"" + S.height + "\">" + S.file + "</bespoke>").firstChild;
  53.       mc.onLoad;
  54.       mc.onReady;
  55.       mc.onReady = function()
  56.       {
  57.          this.nodeData = Tardis.template.nodeSectionData;
  58.          delete Tardis.template.nodeSectionData;
  59.          this.onReady = null;
  60.          this.init();
  61.          this._parent.onReady();
  62.       };
  63.       mc.loadMovie(Tardis.ENGINE_FOLDER + "modules/bespoke.swf");
  64.    }
  65. }
  66. function setShowHide(flag)
  67. {
  68.    var obj;
  69.    for(var o in this)
  70.    {
  71.       obj = this[o];
  72.       if(typeof obj == "movieclip")
  73.       {
  74.          obj._visible = flag;
  75.          !flag ? obj.interrupt() : obj.resume();
  76.       }
  77.    }
  78. }
  79. function setInterruptResume(flag)
  80. {
  81.    var obj;
  82.    for(var o in this)
  83.    {
  84.       obj = this[o];
  85.       if(typeof obj == "movieclip")
  86.       {
  87.          !flag ? obj.interrupt() : obj.resume();
  88.       }
  89.    }
  90. }
  91. function drawLayout()
  92. {
  93.    var ndTemplate = xmlData.firstChild.byName("template");
  94.    var strLayout = ndTemplate.attributes.layout;
  95.    gotoAndStop("l_" + strLayout);
  96. }
  97. function loadModules()
  98. {
  99.    if(loaded == false || Tardis.sideMenu.animating == true)
  100.    {
  101.       return undefined;
  102.    }
  103.    loadInProgress = true;
  104.    ndTemplate = xmlData.firstChild.byName("template");
  105.    pageEditVars = new LoadVars();
  106.    pageEditVars.layout = ndTemplate.attributes.layout;
  107.    pageEditVars.xml_path = xmlData.path;
  108.    ndContent = xmlData.firstChild.byName("content");
  109.    modulePath = Tardis.ENGINE_FOLDER + "modules/";
  110.    nmModules = ndTemplate.childNodes.length;
  111.    nmModulesReady = 0;
  112.    nmModuleCurrent = 0;
  113.    loadNextModule();
  114. }
  115. function loadNextModule()
  116. {
  117.    if(nmModuleCurrent >= nmModules)
  118.    {
  119.       Tardis.loadAdvertButton();
  120.       return undefined;
  121.    }
  122.    var ndModule = ndTemplate.childNodes[nmModuleCurrent];
  123.    var posName = ndModule.attributes.position;
  124.    var mcPosition = this["mc" + posName];
  125.    var strType = ndModule.attributes.type;
  126.    var strNdPath = ndModule.attributes.nodepath;
  127.    var ndModuleData = ndContent.byPath(strNdPath);
  128.    objModuleInitObjects[mcPosition] = {nodeData:ndModuleData};
  129.    pageEditVars["mod_" + nmModuleCurrent + "_position"] = posName;
  130.    pageEditVars["mod_" + nmModuleCurrent + "_type"] = strType;
  131.    pageEditVars["mod_" + nmModuleCurrent + "_nodepath"] = strNdPath;
  132.    pageEditVars["mod_" + nmModuleCurrent + "_data"] = escape(ndModuleData);
  133.    if(strType == "bespoke" && ndModuleData.attributes.sandbox != "true")
  134.    {
  135.       mcPosition.loadMovie(Tardis.ASSETS_FOLDER + "bespoke/" + ndModuleData.getText());
  136.    }
  137.    else
  138.    {
  139.       mcPosition.onReady;
  140.       mcPosition.onReady = function()
  141.       {
  142.          trace("Tardis : template : onReady() called");
  143.          this.onComplete = function()
  144.          {
  145.             trace("onComplete called");
  146.             delete this.onComplete;
  147.             loadNextModule();
  148.          };
  149.          var initObject = Tardis.template.objModuleInitObjects[this];
  150.          for(var o in initObject)
  151.          {
  152.             this[o] = initObject[o];
  153.          }
  154.          delete Tardis.template.objModuleInitObjects[this];
  155.          this.onReady = null;
  156.          this.init();
  157.          this._parent.checkReadyState();
  158.       };
  159.       trace("load file: " + (modulePath + strType + ".swf"));
  160.       mcPosition.loadMovie(modulePath + strType + ".swf");
  161.    }
  162.    if(_root.EDIT_MODE == 1)
  163.    {
  164.       pageEditVars.send("../../../cms/edit.php","edit","POST");
  165.    }
  166.    nmModuleCurrent++;
  167. }
  168. function checkReadyState()
  169. {
  170.    nmModulesReady++;
  171.    if(nmModulesReady == nmModules)
  172.    {
  173.       onReady();
  174.    }
  175. }
  176. var objModuleInitObjects = {};
  177.